/*
 * Copyright (C) 2013 Daniel Treffenstädt <daniel@treffenstaedt.de>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301  USA
 */

#ifndef O_KEYEVENT_H
#define O_KEYEVENT_H

#include "../OGlobal.h"
#include "OEvent.h"
#include "OString.h"

O_START_NAMESPACE

class O_EXPORT KeyEvent : public Event
{
public:
	enum class KeyCode
	{
		None			= 0x00, //!< None
		One				= 0x01, //!< Alphanumeric 1
		Two				= 0x02, //!< Alphanumeric 2
		Three			= 0x03, //!< Alphanumeric 3
		Four			= 0x04, //!< Alphanumeric 4
		Five			= 0x05, //!< Alphanumeric 5
		Six				= 0x06, //!< Alphanumeric 6
		Seven			= 0x07, //!< Alphanumeric 7
		Eight			= 0x08, //!< Alphanumeric 8
		Nine			= 0x09, //!< Alphanumeric 9
		Zero			= 0x0A, //!< Alphanumeric 0
		A				= 0x0B, //!< A
		B				= 0x0C, //!< B
		C				= 0x0D, //!< C
		D				= 0x0E, //!< D
		E				= 0x0F, //!< E

		F				= 0x10, //!< F
		G				= 0x11, //!< G
		H				= 0x12, //!< H
		I				= 0x13, //!< I
		J				= 0x14, //!< J
		K				= 0x15, //!< K
		L				= 0x16, //!< L
		M				= 0x17, //!< M
		N				= 0x18, //!< N
		O				= 0x19, //!< O
		P				= 0x1A, //!< P
		Q				= 0x1B, //!< Q
		R				= 0x1C, //!< R
		S				= 0x1D, //!< S
		T				= 0x1E, //!< T
		U				= 0x1F, //!< U

		V				= 0x20, //!< V
		W				= 0x21, //!< W
		X				= 0x22, //!< X
		Y				= 0x23, //!< Y
		Z				= 0x24, //!< Z
		Space			= 0x25, //!< Space
		Tab				= 0x26, //!< Tabulator
		LBracket		= 0x27, //!< Left Bracket
		RBracket		= 0x28, //!< Right Bracket
		Semicolon		= 0x29, //!< Semicolon
		Comma			= 0x2A, //!< Alhanumeric Comma
		Dot				= 0x2B, //!< Alphanumeric Dot
		Slash			= 0x2C, //!< ALphanumeric Slash
		BackSlash		= 0x2D, //!< Backslash
		Minus			= 0x2E, //!< Alphanumeric Minus
		Equals			= 0x2F, //!< Alphanumeric Equals

		Accent			= 0x30, //!< Accent
		Apostrophe		= 0x31, //!< Apostrophe
		Other			= 0x32, //!< Other
		Num1			= 0x33, //!< Numblock 1
		Num2			= 0x34, //!< Numblock 2
		Num3			= 0x35, //!< Numblock 3
		Num4			= 0x36, //!< Numblock 4
		Num5			= 0x37, //!< Numblock 5
		Num6			= 0x38, //!< Numblock 6
		Num7			= 0x39, //!< Numblock 7
		Num8			= 0x3A, //!< Numblock 8
		Num9			= 0x3B, //!< Numblock 9
		Num0			= 0x3C, //!< Numblock 0
		NumMinus		= 0x3D, //!< Numblock Minus
		NumPlus			= 0x3E, //!< Numblock Plus
		NumDivide		= 0x3F, //!< Numblock Divide

		NumMultiply		= 0x40, //!< Numblock Multiply
		NumComma		= 0x41, //!< Numblock Comma

		NumLock			= 0x42, //!< Numlock
		NumEnter		= 0x43, //!< Numlock Enter
		F1				= 0x44, //!< F1
		F2				= 0x45, //!< F2
		F3				= 0x46, //!< F3
		F4				= 0x47, //!< F4
		F5				= 0x48, //!< F5
		F6				= 0x49, //!< F6
		F7				= 0x4A, //!< F7
		F8				= 0x4B, //!< F8
		F9				= 0x4C, //!< F9
		F10				= 0x4D, //!< F10
		F11				= 0x4E, //!< F11
		F12				= 0x4F, //!< F12

		F13				= 0x50, //!< F13
		F14				= 0x51, //!< F14
		F15				= 0x52, //!< F15
		Esc				= 0x53, //!< Escape
		LMeta			= 0x54, //!< Left Windows
		RMeta			= 0x55, //!< Right Windows
		LCtrl			= 0x56, //!< Left Control
		RCtrl			= 0x57, //!< Right Control
		LAlt			= 0x58, //!< Left Alt
		RAlt			= 0x59, //!< Right Alt
		LShift			= 0x5A, //!< Left Shift
		RShift			= 0x5B, //!< Right Shift
		CapsLock		= 0x5C, //!< Caps Lock
		Home			= 0x5D, //!< Home
		End				= 0x5E, //!< End
		PgUp			= 0x5F, //!< Page up

		PgDown			= 0x60, //!< Page down
		Insert			= 0x61, //!< Insert
		Delete			= 0x62, //!< Delete
		Up				= 0x63, //!< Arrow Up
		Down			= 0x64, //!< Arrow Down
		Left			= 0x65, //!< Arrow Left
		Right			= 0x66, //!< Arrow Right
		Scroll			= 0x67, //!< Scroll Lock
		Return			= 0x68, //!< Return
		Backspace		= 0x69  //!< Backspace
	};

	enum class Modifier
	{
		None			= 0b00000001, //!< None
		ShiftL			= 0b00000010, //!< Left Shift
		ShiftR			= 0b00000100, //!< Right Shift
		CtrlL			= 0b00001000, //!< Left Control
		CtrlR			= 0b00010000, //!< Right Control
		MetaL			= 0b00100000, //!< Left Meta Modifier (Windows Key)
		MetaR			= 0b01000000, //!< Right Meta Modifier (Windows Key)
		AltL			= 0b01000000, //!< Left Alt
		AltR			= 0b10000000  //!< Right Alt (AltGR)
	};

	enum class Action
	{
		Press,		//!< Key Press
		Release		//!< Key Release
	};

private:
	KeyCode			m_key;
	Modifier		m_modifier;
	Action			m_action;
	String			m_text;

public:
	KeyEvent(KeyCode key, Modifier modifier, Action action, String text);
	KeyCode key();
	Modifier modifier();
	Action action();
	String text();
};

O_END_NAMESPACE

#endif // O_KEYEVENT_H
